# -*- coding: utf-8 -*-
# created on 2016/10/7

from sympy import solveset
from mathsolver.functions.base import *


class WeiZhiGuanXiTof(BaseFunction):
    def solver(self, *args):

        f1, f2 = args[0].sympify()
        f3, f4 = args[1].sympify()

        eq1 = (f1 - f2).simplify()
        eq2 = (f3 - f4).simplify()

        if str(eq1) == str(eq2):
            answer = True
        else:
            ans1 = solveset(f1 - f2, None, S.Reals)
            ans2 = solveset(f3 - f4, None, S.Reals)

            if ans1 == ans2:
                answer = True
            else:
                answer = False

        if answer:
            self.steps.append(["", "%s与%s等价" % (self.output_eq([f1, f2]), self.output_eq([f3, f4]))])
        else:
            self.steps.append(["", "%s与%s不等价" % (self.output_eq([f1, f2]), self.output_eq([f3, f4]))])

        self.label.add("判断方程是否正确")
        self.output.append(BaseVariable(answer))
        return self


if __name__ == '__main__':
    pass
